package org.goobs.mapping;

import java.util.HashMap;
import java.util.Map;

import org.goobs.database.DatabaseRow;

public class RoadNode implements DatabaseRow{

	public static final String[] COLS = {"node_id", "node_index", "osm_way_id"};
	public static final String[] TYPES = {"INT", "INT", "INT"};
	public static final String[] INDEX = {"node_id", "osm_way_id"};
	
	private int wayId, index, nodeRef;
	
	protected RoadNode(){
		
	}
	
	protected RoadNode(int wayId, int index, int nodeRef){
		recycle(wayId, index, nodeRef);
	}
	
	public void recycle(int wayId, int index, int nodeRef){
		this.wayId = wayId;
		this.index = index;
		this.nodeRef = nodeRef;
	}
	
	public int getWayId(){
		return wayId;
	}
	
	public int getIndex(){
		return index;
	}
	
	public int getNodeRef(){
		return nodeRef;
	}
	
	@Override
	public Map<String, Object> export() {
		Map <String, Object> export = new HashMap <String, Object> ();
		export.put("osm_way_id", wayId);
		export.put("node_index", index);
		export.put("node_id", nodeRef);
		return export;
	}

	@Override
	public void load(Map<String, Object> row) {
		wayId = (Integer) row.get("osm_way_id");
		index = (Integer) row.get("node_index");
		nodeRef = (Integer) row.get("node_id");
	}

	
	
}
